//package com.jiuhe.handi.app.account.order.fragment;
//
//import android.app.Activity;
//import android.content.Intent;
//import android.os.Bundle;
//import android.support.v7.widget.LinearLayoutManager;
//import android.support.v7.widget.RecyclerView;
//import android.view.View;
//
//import com.chad.library.adapter.base.BaseQuickAdapter;
//import com.jiuhe.handi.Logger;
//import com.jiuhe.handi.MainActivityCompent;
//import com.jiuhe.handi.R;
//import com.jiuhe.handi.app.Navigation;
//import com.jiuhe.handi.app.account.adapter.PacketInfoAdapter;
//import com.jiuhe.handi.app.photo.model.ImageItem;
//import com.jiuhe.handi.common.data.utils.FileUtil;
//import com.jiuhe.handi.common.data.utils.ui.ToastUtil;
//import com.jiuhe.handi.common.structure.PhotoManager;
//import com.jiuhe.handi.common.structure.mvp.BasePresenter;
//import com.jiuhe.handi.common.structure.presenter.photo.PhotoContract;
//import com.jiuhe.handi.common.structure.presenter.photo.PhotoPresenter;
//import com.jiuhe.handi.common.structure.ui.fragment.LoadingFragment;
//import com.jiuhe.handi.constant.Constant;
//import com.jiuhe.handi.models.remote.account.PicPath;
//import com.jiuhe.handi.models.remote.account.order.BigOrder;
//import com.jiuhe.handi.models.remote.account.order.OrderStatus;
//import com.jiuhe.handi.models.remote.account.order.PacketStatus;
//import com.jiuhe.handi.models.result.ResultBean;
//
//import java.io.File;
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.inject.Inject;
//
//import butterknife.BindView;
//
///**
// * Created by SEELE on 2019/2/13.
// */
//
//public class PacektInfoFragment extends LoadingFragment implements OrderStatusContract.View, PacketInfoContract.View, PhotoContract.View {
//    @BindView(R.id.recycler_view)
//    RecyclerView mRecyclerView;
//
//    @Inject
//    OrderStatusPresenter mStatusPresenter;
//    private String mStatus;
//    private PacketInfoAdapter mPacketInfoAdapter;
//
//    @Inject
//    PacketInfoPresenter mInfoPresenter;
////    private ConfirmReciveDialog mConfirmReciveDialog;
//    @Inject
//    FileUtil mFileUtil;
//        File mFile;
//    @Inject
//    PhotoPresenter mPhotoPresenter;
//    private PacketStatus mPacketStatus;
//    private List<PicPath> mPicPaths;
//    private int mPicCount;
//
//
//    @Override
//    protected int contentLayout() {
//        return R.layout.fragment_order;
//    }
//
//    @Override
//    protected void clickRetry(View v) {
//
//    }
//
//    @Override
//    protected void initData() {
////        mConfirmReciveDialog = new ConfirmReciveDialog(getActivity(), mFragment);
//    }
//
//    @Override
//    protected void initEvents() {
//        mPacketInfoAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
//            @Override
//            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
//                Navigation.goPacketDetail(getActivity(), mPacketInfoAdapter.getData().get(position).getPg_id());
//            }
//        });
//        mPacketInfoAdapter.setOnItemConfirmLinstener(new PacketInfoAdapter.OnItemConfirmLinstener() {
//            @Override
//            public void onConfirm(int position) {
//                mPacketStatus = mPacketInfoAdapter.getData().get(position);
//                if ("2".equals(mStatus)) {
//                    mInfoPresenter.onConfirmRecive(mPacketStatus.getPg_id());
//                } else if (mPacketStatus.getIs_comment() == 0) {
//                        Navigation.goConfirmOrder(getActivity());
////                    mConfirmReciveDialog.setOnSubmitLinstener(new OnSubmitLinstener() {
////                        @Override
////                        public void onSubmit(String starts, String reason, String imageUrls) {
////                            mInfoPresenter.onComment(starts, mPacketStatus.getPg_id(), String.valueOf(mConfirmReciveDialog.getPhotos().size() - 1), reason);
////                        }
////                    });
////                    mConfirmReciveDialog.show();
//                }
//
//            }
//        });
//
////        mConfirmReciveDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
////            @Override
////            public void onDismiss(DialogInterface dialog) {
////                mConfirmReciveDialog.clearData();
////            }
////        });
//    }
//
//    @Override
//    protected void initViews() {
//        mStatusPresenter.onCreate(this);
//        mInfoPresenter.onCreate(this);
//        mPhotoPresenter.onCreate(this);
//        mStatus = getArguments().getString(Constant.STATUS);
//
//
//        mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
//        mPacketInfoAdapter = new PacketInfoAdapter(null, mStatus);
//        mRecyclerView.setAdapter(mPacketInfoAdapter);
//
//        mStatusPresenter.getPacketInfo(mStatus);
//
//
//    }
//
//    @Override
//    public void initInjector() {
//        getComponent(MainActivityCompent.class).inject(this);
//    }
//
//    @Override
//    protected BasePresenter getPresenter() {
//        return mStatusPresenter;
//    }
//
//    public static PacektInfoFragment newInstance(String status) {
//        Bundle args = new Bundle();
//        PacektInfoFragment fragment = new PacektInfoFragment();
//        args.putString(Constant.STATUS, status);
//        fragment.setArguments(args);
//        return fragment;
//    }
//
//    @Override
//    public void showLoading() {
//
//    }
//
//    @Override
//    public void hideLoading() {
//
//    }
//
//    @Override
//    public void error(String msg) {
//        ToastUtil.getToastUtil().showShort(msg);
//    }
//
//    @Override
//    public void error(int code, String msg) {
//        ToastUtil.getToastUtil().showShort(msg);
//    }
//
//    @Override
//    public void getPendingSuccess(List<OrderStatus> orderStatuses) {
//
//    }
//
//    @Override
//    public void getPacketInfoSuccess(List<PacketStatus> packetStatuses) {
//        mStatusLayoutManager.showContent();
//        mPacketInfoAdapter.setNewData(packetStatuses);
//    }
//
//    @Override
//    public void getOrderStatusSuccess(BigOrder orderStatuses) {
//
//    }
//
//    @Override
//    public void cancelOrderSuccess(ResultBean resultBean) {
//
//    }
//
//
//    @Override
//    public void onConfirmReciveSuccess(ResultBean resultBean) {
//        if ("1".equals(resultBean.getStatus())) {
//            mStatusPresenter.getPacketInfo(mStatus);
//            ToastUtil.getToastUtil().showShort(getString(R.string.confirm_order_succeess));
//        } else {
//            ToastUtil.getToastUtil().showShort(resultBean.getMsg());
//        }
//    }
//
//
//    @Override
//    public void onUploadPhotosSuccess(ResultBean resultBean) {
//        if (mPicPaths != null && mPicPaths.size() > 1) {
//            mPicPaths.remove(0);
//            upload();
//        } else {
////            mConfirmReciveDialog.dismiss();
//            ToastUtil.getToastUtil().showShort(getString(R.string.comment_success));
//
//        }
//
//    }
//
//    @Override
//    public void onCommentSuccess(ResultBean resultBean) {
////        mPicPaths = mConfirmReciveDialog.getPhotos();
//        mPicCount = mPicPaths.size();
//        if (mPicPaths.size() == 1) {
//            ToastUtil.getToastUtil().showShort(getString(R.string.comment_success));
//            return;
//        }
//        upload();
//
//
//    }
//
//    public void upload() {
//        if (mPicPaths != null && mPicPaths.size() > 0) {
//            mInfoPresenter.onUploadPhotos(mPicPaths.get(0).getFile(), mPacketStatus.getPg_id(), String.valueOf(mPicCount - mPicPaths.size() - 1));
//        }
//    }
//
//    @Override
//    public void compressComplete(File file) {
//        Logger.e("Thread:" + Thread.currentThread());
////        if (mConfirmReciveDialog != null)
////            mConfirmReciveDialog.onSetFiles(file);
//    }
//
//    @Override
//    public void photoCallback(String path) {
//
//    }
//
//    @Override
//    public void onActivityResult(int requestCode, int resultCode, Intent data) {
//        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode == Activity.RESULT_OK) {
//            switch (requestCode) {
//                case PhotoManager.REQUEST_CODE_CHECK_IMAGE:
//                    //选择图片回调 并裁剪
//                    ArrayList<ImageItem> path = data.getParcelableArrayListExtra("path");
////                    mFile = new File(mFileUtil.getHeaderDir().getPath(), System.currentTimeMillis() + ".jpg");
//                    mPhotoPresenter.compressPhoto(new File(path.get(0).getImagePath()));
////                    PhotoManager.crop(this, mFile, new File(path.get(0).getImagePath()), PhotoManager.REQUEST_CODE_CROP_CODE);
//                    break;
//                case PhotoManager.REQUEST_CODE_OPEN_CAMERA:
//                    //相机回调
////                    PhotoManager.crop(this, mFile, mFile, PhotoManager.REQUEST_CODE_CROP_CODE);
////                    mFile = mConfirmReciveDialog.getFile();
//                    if (mFile!=null)
//                    mPhotoPresenter.compressPhoto(mFile);
//                    break;
//                case PhotoManager.REQUEST_CODE_CROP_CODE:
//                    //裁剪回调
//                    //压缩
//                    break;
//
//            }
//        }
//
//    }
//}
